import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsArray,
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsString,
} from 'class-validator';

export class CreatePostDto {
  @ApiProperty({ description: '文章标题' })
  @IsNotEmpty({ message: '文章标题必填' })
  readonly title: string;

  @ApiPropertyOptional({ description: '内容' })
  @IsNotEmpty({ message: '内容不能为空' })
  @IsString()
  readonly content: string;

  @IsNumber()
  @ApiProperty({ description: '文章分类' })
  @IsNotEmpty({ message: '文章分类必填' })
  readonly category: number;

  @ApiPropertyOptional({ description: '文章标签' })
  @IsNotEmpty({ message: '文章标签必填' })
  @IsArray()
  readonly tags: number[];

  @ApiPropertyOptional({ description: '文章封面' })
  @IsString()
  readonly coverUrl?: string = '';

  @ApiPropertyOptional({ description: '文章状态' })
  @IsEnum(['draft', 'publish'])
  readonly status?: string = 'draft';

  @ApiPropertyOptional({ description: '是否推荐' })
  readonly isRecommend?: boolean = false;
}
